package com.ruoyi.cmelasercladding.controller;

import com.ruoyi.cmelasercladding.domain.ZxLaserCladdingOrderForm;
import com.ruoyi.cmelasercladding.service.IZxLaserCladdingOrderFormService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * LaserCladdingOrderController
 * 
 * @author zhangxu
 * @date 2021-12-16
 */
@RestController
@RequestMapping("/LaserCladding/LaserCladdingOrder")
public class ZxLaserCladdingOrderFormController extends BaseController
{
    @Autowired
    private IZxLaserCladdingOrderFormService zxLaserCladdingOrderFormService;

    /**
     * 查询LaserCladdingOrder列表
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxLaserCladdingOrderForm zxLaserCladdingOrderForm)
    {
        startPage();
        List<ZxLaserCladdingOrderForm> list = zxLaserCladdingOrderFormService.selectZxLaserCladdingOrderFormList(zxLaserCladdingOrderForm);
        return getDataTable(list);
    }

    /**
     * 导出LaserCladdingOrder列表
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:export')")
    @Log(title = "LaserCladdingOrder", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxLaserCladdingOrderForm zxLaserCladdingOrderForm)
    {
        List<ZxLaserCladdingOrderForm> list = zxLaserCladdingOrderFormService.selectZxLaserCladdingOrderFormList(zxLaserCladdingOrderForm);
        ExcelUtil<ZxLaserCladdingOrderForm> util = new ExcelUtil<ZxLaserCladdingOrderForm>(ZxLaserCladdingOrderForm.class);
        util.exportExcel(response, list, "LaserCladdingOrder数据");
    }

    /**
     * 获取LaserCladdingOrder详细信息
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zxLaserCladdingOrderFormService.selectZxLaserCladdingOrderFormById(id));
    }

    /**
     * 新增LaserCladdingOrder
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:add')")
    @Log(title = "LaserCladdingOrder", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxLaserCladdingOrderForm zxLaserCladdingOrderForm)
    {
        return toAjax(zxLaserCladdingOrderFormService.insertZxLaserCladdingOrderForm(zxLaserCladdingOrderForm));
    }

    /**
     * 修改LaserCladdingOrder
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:edit')")
    @Log(title = "LaserCladdingOrder", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxLaserCladdingOrderForm zxLaserCladdingOrderForm)
    {
        System.out.println("==========================chengong" + zxLaserCladdingOrderForm.toString());
        return toAjax(zxLaserCladdingOrderFormService.updateZxLaserCladdingOrderForm(zxLaserCladdingOrderForm));
    }

    /**
     * 删除LaserCladdingOrder
     */
    @PreAuthorize("@ss.hasPermi('LaserCladding:LaserCladdingOrder:remove')")
    @Log(title = "LaserCladdingOrder", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxLaserCladdingOrderFormService.deleteZxLaserCladdingOrderFormByIds(ids));
    }
}
